home *** CD-ROM | disk | FTP | other *** search
- (Whatever is described below was checked for a gulam version
- which identifies itself as:
-
- beta test version 1.03.04.05 121887 of
- yet another shell for AtariST/TOS
-
- Your mileage may vary!!)
-
- As you may not know, a very popular Gulam shell (many thanks to
- Prabhaker Mateti and Jwahar R. Bammi). includes quite powerful facility
- to invoke gulam services from a program started from gulam. In contrast
- to many others shells floating aroung this is not done by executing
- the next incarnation of gulam. Instead there are provided two pointers
- which provide execution 'hooks' for all gulam commands. A bright sight
- is that this approach does not take any extra memory and a start-up
- time is negligible. A dark side is that documentation describing this
- facility is either misleading or plainly wrong. (As an aside - this
- is, alas, not the only place in documentation requiring touch-up.
- For this version, gulam.hlp, for example, does not correspond very well
- tp reality).
-
- This note is a kind of erratum, which, hopefuly, will help to clarify
- an ensuing confusion, which seems to be quite widespread.
-
- When you are running Gulam a TOS variable '_shell_p', at 0x4f6,
- contains an address of a location named 'togu_', which is the last entry
- in a 16 byte long table. The format of the table is (this is mostly quoted
- from the documentation):
-
- .long 0x86420135 / our magic number (4 bytes)
- jmp getlineviaue_ / 0x4ef9,address (6 bytes)
- togu_: jmp callgulam_ / 0x4ef9,address (6 bytes)
-
- It clearly follows from that that magic number is located 10 bytes before
- 'togu_' and not, the documentation suggested, 12. What's more, the magic
- number should be equal *(long *)(*(char **)0x4f6 - 10), instead of a
- given *((long *)0x46fL - 12L), which will produce a value from an address
- way off. On the top of it, an actual magic number in my copy of Gulam
- is not like the documented but it equals 0x00420135. Use Gulam 'peekw'
- to check what you got. To be on a safe side, until the matter
- is fully clarified, I am using only a lower half of the magic number,
- which seems to be correct; i.e. short_magic = *(short *)(*(char **)0x4f6-8).
-
- Two other items in the table are entry points to two functions
- 'getlineviaue' and 'callgulam'. The information given in the documentation
- about them is mostly correct, with a similar mix-up in a calculation
- of an address of entry to 'getlineviaue', like the one described above.
- Also, strictly speaking, 'getlinevalue' does not return anything, since
- it is declared as 'void'. As a side effect it modifies a contents of
- a user supplied buffer, copying there a contents of a command line. It
- would be probably more convenient if, instead of being void, it would return
- something useful, say a number of copied characters, but it doesn't,
- so we may have to live with that. Just to make our life more
- interesting, the other function, 'callgulam', returns 'int' - the return
- status of an executed command. This makes wonders to types of your
- pointers. See the supplied program example for to see how to cast.
- All of this to ensure that your C-compiler will not get totally lost.
- If you have a compiler which accepts the stuff in a form from an original
- docs - replace your compiler. Fast!
- (As an aside - all this pointer play would be easier in assembler,
- if you feel so inclined).
-
- While experimenting whith the program example try the following.
- Call 'ue' on some file, position cursor somewher down the text and
- stop editor with ^Z. Try some other commands and upon return to Gulam
- type 'fg'. Repeat experiment stopping the editor in Gulam and typing
- 'fg' from the demo program prompt. Don't you think that this is a nice
- way to run editor for your, say, Lisp interpreter?
-
- Some things are still missing. One cannot tell 'ue', on a command
- line, to load a file and go to the line 247. Or there is a way and I
- am simply not aware of it? And I know of no way to grab a result of
- a command, stuff it into a variable and use it for a test of conditional
- script execution. Oh well, maybe in some future release...
-
- Two other, non-interactive, ways of calling Gulam are also mentioned
- in docs. I did not try 'Pexec method', but attempts to execute
- gulam as a program with arguments, as described, produced only
- nonsensical error messages about 'invalid regexp' and error number -33.
- Can anybody shed some light on that matter?
-
-
- Michal Jaegermann
- Myrias Research Corporation
- Edmonton, Alberta, CANADA
- ...alberta!myrias!mj
- (or you may try mj@myrias.UUCP)
-
- ------------------------------------------------------------------------------
-
- /*
- * A demo program to show a usage of Gulam 'hooks' - call from
- * Gulam shell! When asked, try different gulam commands, ue
- * in particular.
- *
- * A numbers of pointers floating around is a little bit higher
- * than necessary, but we will waiste some memore for the sake
- * of clarity.
- *
- * Michal Jaegermann, October 1988
- */
-
- #include <stdio.h>
- #include <osbind.h>
- #include <string.h>
- #define SHELLP ((char **) 0x04f6L)
- #define G_MAGIC 0x0135
-
- main()
- {
- long save_ssp;
- short sh_magic;
- char buf[258];
- char *tgptr; /* storage for togu_ */
- /* if you really would like to have it right, then */
- /* tgptr should be a pointer to void - */
- /* a bit of overkill on ST :-) */
-
-
- int (* cgp)(); /* pointer to callgulam() */
- /* also contains togu_, but */
- /* a type is different */
- void (* glp)(); /* pointer to getlineviaue() */
-
- fprintf(stderr, "Welcome to callgulam demo.\n");
- save_ssp = Super(0L);
- tgptr = *SHELLP;
- Super(save_ssp);
-
- if (G_MAGIC != (sh_magic = *((short *)(tgptr - 8)))) {
- fprintf (stderr, "wrong magic value %x\n", sh_magic);
- exit (1);
- }
-
- cgp = *((int (*)()) tgptr);
- glp = *((void (*)()) (tgptr - 6));
- (* cgp)("echo 'test of Gulam'");
- (* cgp)("echo 'executing ls -l'");
- (* cgp)("ls -l");
- (* cgp)("echo '-----------------'");
- (* cgp)("ls -R -t a:\\ ");
- (* cgp)("echo ' '");
- (* cgp)("echo ' '");
- (* cgp)("set tmp_old_prompt $prompt");
- (* cgp)("set prompt 'At your service, Sir!'");
- /* change a gender if a need will arise */
- (* cgp)("echo 'Awaiting your commands!!'");
- /* the following loop will cycle until it will get an empty line */
- while ((* glp)(buf), putchar('\n'), 0 != strlen(buf)) {
- /* the new line not supplied */
- /* by Gulam - DIY, mate */
- (* cgp)(buf);
- }
- (* cgp)("set prompt $tmp_old_prompt");
- (* cgp)("unset tmp_old_prompt");
- fprintf (stderr,"\nNice talking to you, see you later.\n");
- exit(0);
- }
- /* -----------------/ that is all for today /--------------------- */
-
- --
- Michal Jaegermann
- Myrias Research Corporation
- Edmonton, Alberta, CANADA
- ...{ihnp4, ubc-vision}!elberta!myrias!mj
-